#include<iostream>
#include <iomanip>
using namespace std;

bool book[25];
int a[25];
int n,r;

void dfs(int t){
    for(int i=1; i<=n; i++){
        if(book[i] == 0 && i>a[t-1])
        {
            a[t]=i;
            book[i]=1;
            if(t==r){
                for(int j=1; j<=r; j++)
                    cout<<setw(3)<<a[j];
                cout<<endl;
            }
            else
                dfs(t+1);
            book[i]=0;
        }
    }
}

int main()
{
    cin>>n>>r;
    dfs(1);
    return 0;
}

